package com.api.shopapi.mapper;


import com.api.shopapi.entity.BusinessStaffRel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface BusinessStaffRelMapper {

    @Insert("insert into business_staff_rel" +
            "(BusinessStaffRelCode," +
            "BusinessCode," +
            "StaffCode)" +
            "values " +
            "(" +
            "#{businessStaffRel.businessStaffRelCode}," +
            "#{businessStaffRel.BusinessCode}," +
            "#{businessStaffRel.StaffCode}" +
            ")")
    int insert(@Param("businessStaffRel") BusinessStaffRel businessStaffRel);


    @Update("update business_staff_rel set " +
            "BusinessCode=#{businessStaffRel.BusinessCode}," +
            "StaffCode=#{businessStaffRel.StaffCode}" +
            " where " +
            "businessStaffRelCode=#{businessStaffRel.BusinessStaffRelCode}")
    int update(@Param("businessStaffRel") BusinessStaffRel businessStaffRel);

    @Select("select * from business_staff_rel where businessStaffRelCode=#{businessStaffRelCode} limit 1")
    BusinessStaffRel getByBusinessStaffRelCode(@Param("businessStaffRelCode") String businessStaffRelCode);

    @Select("select * from business_staff_rel where staffCode=#{staffCode} limit 1")
    BusinessStaffRel getByStaffCode(@Param("staffCode") String staffCode);

    @Select("select * from business_staff_rel where businessCode=#{businessCode}")
    List<BusinessStaffRel> getListByBusinessCode(@Param("businessCode") String businessCode);

    @Delete("delete from business_staff_rel where businessStaffRelCode=#{businessStaffRelCode}")
    int deleteByBusinessStaffRelCode(@Param("businessStaffRelCode") String businessStaffRelCode);

    @Select("select * from business_staff_rel where staffCode=#{staffCode}")
    List<BusinessStaffRel> getListByStaffCode(String staffCode);



}
